package com.rpoonolly.simplegame.renderer;

import java.awt.Graphics;

import javax.vecmath.Point2d;

import com.rpoonolly.simplegame.Config;
import com.rpoonolly.simplegame.core.Renderer;
import com.rpoonolly.simplegame.core.aabb.AABBEntity;

public abstract class SimpleSwingRenderer implements Renderer {
	protected Graphics graphics;
	protected volatile double windowWidth, windowHeight;
	protected Point2d focalPoint = new Point2d();
	
	public void clearScreen() {
		graphics.setColor(Config.COLOR_BACKGROUND);
		graphics.fillRect(0, 0, (int) windowWidth, (int) windowHeight);
	}
	
	public Point2d getFocalPoint() {
		return focalPoint;
	}

	public void setFocalPoint(AABBEntity focus) {
		focalPoint.x = focus.getX() + (focus.getWidth() / 2);
		focalPoint.y = focus.getY() + (focus.getHeight() / 2);
	}
	
	public Graphics getGraphics() {
		return graphics;
	}
	
	public void setGraphics(Graphics graphics) {
		this.graphics = graphics;
	}
	
	public double getWindowWidth() {
		return windowWidth;
	}
	
	public void setWindowWidth(double windowWidth) {
		this.windowWidth = windowWidth;
	}
	
	public double getWindowHeight() {
		return windowHeight;
	}
	
	public void setWindowHeight(double windowHeight) {
		this.windowHeight = windowHeight;
	}
}
